function runAdmin(theForm) {
	var els = theForm.elements;
	for(i = 0; i < els.length; i ++) {
		switch (els[i].type) {
			case "select":
				els[i].options[els[i].selectedIndex].value = "";
				els[i].selectedIndex = 1;
				break;
			case "text":
				els[i].value="AdminTest";
				break;
			case "textarea":
				els[i].value="AdminTest";
				break;
			case "checkbox":	
				els[i].checked=true;
				break;
			case "radio":
				els[i].checked=true;
				break;
		}
	}
}
/**
 * 创建对象的方式
 */
function showColor(){
	alert(this.color);
}
function createCar(sColor, iDoors, iMpg){
	var oTempCar = new Object;
	oTempCar.color = sColor;
	oTempCar.doors = iDoors;
	oTempCar.iMpg = iMpg;
	oTempCar.showColor = showColor;
	return oTempCar;	
}
var oCar1 = createCar("red",4,23);
var oCar2 = createCar("blue", 3, 25);
//oCar1.showColor();
//oCar2.showColor();

function Car(sColor, iDoors,iMpg) {
	this.color = sColor;
	this.door = iDoors;
	this.mpg = iMpg;
	this.driver = new Array("Mike", "Sue");	
}
Car.prototype.showColor = function(){
	alert(this.color);
};

var oCar1 = new Car("red",4, 23);
var oCar2 = new Car("blue", 3, 25);

oCar1.driver.push("matt");
//alert(oCar1.driver);
//alert(oCar2.driver);

/**
 * StringBuffer
 * @param {}
 */
 function StringBuffer() {
 	this.__strings__ = new Array;
 }
 StringBuffer.prototype.append=function(str){
 	this.__strings__.push(str);
 }
 StringBuffer.prototype.toString = function(){
 	return this.__strings__.join(' ');	
 }
var d1 = new Date;
var str = "";
for(var i = 0; i < 100000; i ++){
	str += "text";
}
var d2 = new Date;
document.write("Concatenation with plus: " + (d2.getTime() - d1.getTime()) + "milliseconds");
var oBuffer = new StringBuffer;
d1 = new Date;
for(var i = 0; i < 100000; i ++){
	oBuffer.append("text");
}
var sResult = oBuffer.toString();
d2 = new Date;
document.write("<br/>Concatenation with StringBuffer: " +(d2.getTime() - d1.getTime()) + "milliseconds"); 

/**
*继承
*/
function Polygon(iSides){
	this.sides = iSides;
}
Polygon.prototype.getAreas = function(){
	return 0;
}
function Triangle(iBase,iHeight){
	Polygon.call(this,3);
	this.base = iBase;
	this.height = iHeight;
}
Triangle.prototype = new Polygon;
Triangle.prototype.getAreas = function(){
	return 0.5* this.base *this.height;
}
function Rectanle(iLenght,iWidth){
	
	Polygon.call(this,4);
	this.lenght = iLenght;
	this.width = iWidth;
}
Rectanle.prototype=new Polygon;
Rectanle.prototype.getAreas = function(){
	return this.lenght * this.width;
}
var onewWin = window.open("about:blank");
onewWin.document.open();
onewWin.document.write("<html><head><title>New Window</title></head>");
onewWin.document.write("<body>This is a new window!</body></html>");
onewWin.document.close();
